package com.example.schoolenterprisealliance.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.schoolenterprisealliance.MainActivity;
import com.example.schoolenterprisealliance.R;
import com.example.schoolenterprisealliance.activity.DynamicActivity;
import com.example.schoolenterprisealliance.activity.InternetActivity;
import com.example.schoolenterprisealliance.activity.IntroduceActivity;
import com.example.schoolenterprisealliance.activity.PolicyActivity;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class MyDialog extends Dialog {
    private ImageView img_back;
    private Context context;
    private TextView main;        //首页
    private TextView introduce;   //联盟介绍
    private TextView dynamic;     //最新动态
    private TextView policy;      //最新政策
    private TextView internet;    //会联网+
    private Intent intent;
    public MyDialog( Context context) {
        super(context);
        this.context=context;
    }
    public MyDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        this.context=context;
    }
    protected MyDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        this.context=context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.dialog_main);
        initview();
        to(context);
    }
    private void initview() {
            img_back=(ImageView) findViewById(R.id.close);
            img_back.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    MyDialog.this.dismiss();
                }
            });

    }
    private void to(final Context context){
        main=findViewById(R.id.tv_main) ;
        introduce=findViewById(R.id.tv_introduce) ;
        dynamic=findViewById(R.id.tv_dynamic) ;
        policy =findViewById(R.id.tv_policy) ;
        internet=findViewById(R.id.tv_internet) ;
            main.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    intent=new Intent(context,MainActivity.class);
                    context.startActivity(intent);
                    }
                });
                introduce.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        intent=new Intent(context,IntroduceActivity.class);
                        context.startActivity(intent);
                    }
                });
                dynamic.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        intent=new Intent(context, DynamicActivity.class);
                        context.startActivity(intent);
                    }
                });
                policy.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        intent=new Intent(context, PolicyActivity.class);
                        context.startActivity(intent);
                    }
                });
                internet.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        intent=new Intent(context, InternetActivity.class);
                        context.startActivity(intent);
                    }
                });
        }
    }

